package com.ruoyi.project.system.kind.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PageQuery;
import com.ruoyi.framework.web.page.TableData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.kind.mapper.InfoKindMapper;
import com.ruoyi.project.system.kind.domain.InfoKind;
import com.ruoyi.project.system.kind.service.IInfoKindService;

/**
 * webService业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-12
 */
@Service
public class InfoKindServiceImpl implements IInfoKindService 
{
    @Autowired
    private InfoKindMapper infoKindMapper;

    /**
     * 查询web
     * 
     * @param id web主键
     * @return web
     */
    @Override
    public InfoKind selectInfoKindById(Long id)
    {
        return infoKindMapper.selectById(id);
    }



    /**
     * 新增web
     * 
     * @param infoKind web
     * @return 结果
     */
    @Override
    public int insertInfoKind(InfoKind infoKind)
    {
        infoKind.setCreateTime(DateUtils.getNowDate());
        return infoKindMapper.insert(infoKind);
    }

    /**
     * 修改web
     * 
     * @param infoKind web
     * @return 结果
     */
    @Override
    public int updateInfoKind(InfoKind infoKind)
    {
        infoKind.setUpdateTime(DateUtils.getNowDate());
        return infoKindMapper.updateById(infoKind);
    }

    /**
     * 批量删除web
     * 
     * @param ids 需要删除的web主键
     * @return 结果
     */
    @Override
    public int deleteInfoKindByIds(String ids)
    {
        List<String> collect = Arrays.stream(ids.split(",")).collect(Collectors.toList());
        return infoKindMapper.deleteBatchIds(collect);
    }

    /**
     * 删除web信息
     * 
     * @param id web主键
     * @return 结果
     */
    @Override
    public int deleteInfoKindById(Long id)
    {
        return infoKindMapper.deleteById(id);
    }

    @Override
    public TableData<InfoKind> selectList(InfoKind infoKind, PageQuery pageQuery) {
        LambdaQueryWrapper<InfoKind> lqw = new LambdaQueryWrapper<>();
        lqw.like(StringUtils.isNoneBlank(infoKind.getKindName()), InfoKind::getKindName,infoKind.getKindName());
        Page<InfoKind> page = infoKindMapper.selectPage(pageQuery.build(), lqw);
        return TableData.build(page);
    }

    @Override
    public List<InfoKind> alllist() {
        List<InfoKind> list = infoKindMapper.selectList(null);
        return list;
    }
}
